package controllers;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import models.Customer;

import play.mvc.Controller;

public class TestJPA extends Controller {
	public static void index() {
		try {
			Class c = TestJPA.class;
			Method m[] = c.getDeclaredMethods();
			ArrayList<String> methodNames = new ArrayList<String>();
			for (int i = 1; i < m.length; i++) {
				methodNames.add(m[i].getName());
			}
			render(methodNames);
		} catch (Throwable e) {
			System.err.println(e);
		}
	}
	public static void getAllCustomers() {
		String output = "";
		List<Customer> customers = Customer.findAll();
		
		for (Customer customer : customers) {
			output += "username: ";
			output += customer.username + "\n";
			output += "firstname: ";
			output += customer.firstname + "\n";
			output += "lastname: ";
			output += customer.lastname + "\n";
			output += "password: ";
			output += customer.password + "\n";
			output += "------------------\n\n";
		}
		renderText(output);
	}
	
	
	public static void getOneCustomers(){
		String username="karen";
		Customer customer = Customer.find("username","pat").first();
		//System.out.println(customer.firstname+customer.lastname);
		//renderText(customer.firstname);
		render("Customer/portfolio.html");
	}
}
